package com.kexio.user.service;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * 用户业务统计服务接口
 * 
 * 🎯 职责：
 * - 提供用户、角色、权限、租户等业务数据的统计分析
 * - 正确架构：业务统计服务位于业务模块中
 * 
 * @author Kexio Team
 * @since 2.2.0
 */
public interface UserStatisticsService {

    /**
     * 获取综合业务统计
     */
    BusinessStatistics getBusinessStatistics();

    /**
     * 获取用户概览统计
     */
    UserOverviewStatistics getUserOverview();

    /**
     * 获取角色分布统计
     */
    Map<String, Long> getRoleDistribution();

    /**
     * 获取租户统计数据
     */
    TenantStatistics getTenantStatistics();

    /**
     * 获取权限使用统计
     */
    Map<String, Long> getPermissionUsageStatistics();

    /**
     * 综合业务统计数据
     */
    class BusinessStatistics {
        private Long totalUsers;              // 总用户数
        private Long activeUsers;             // 活跃用户数
        private Long onlineUsers;             // 在线用户数
        private Map<String, Long> permissionUsageStats; // 权限使用统计
        private Map<String, Long> roleDistribution;     // 角色分布
        private TenantStatistics tenantStats;           // 租户统计
        private LocalDateTime timestamp;      // 统计时间

        // Getters and Setters
        public Long getTotalUsers() { return totalUsers; }
        public void setTotalUsers(Long totalUsers) { this.totalUsers = totalUsers; }

        public Long getActiveUsers() { return activeUsers; }
        public void setActiveUsers(Long activeUsers) { this.activeUsers = activeUsers; }

        public Long getOnlineUsers() { return onlineUsers; }
        public void setOnlineUsers(Long onlineUsers) { this.onlineUsers = onlineUsers; }

        public Map<String, Long> getPermissionUsageStats() { return permissionUsageStats; }
        public void setPermissionUsageStats(Map<String, Long> permissionUsageStats) { this.permissionUsageStats = permissionUsageStats; }

        public Map<String, Long> getRoleDistribution() { return roleDistribution; }
        public void setRoleDistribution(Map<String, Long> roleDistribution) { this.roleDistribution = roleDistribution; }

        public TenantStatistics getTenantStats() { return tenantStats; }
        public void setTenantStats(TenantStatistics tenantStats) { this.tenantStats = tenantStats; }

        public LocalDateTime getTimestamp() { return timestamp; }
        public void setTimestamp(LocalDateTime timestamp) { this.timestamp = timestamp; }
    }

    /**
     * 用户概览统计
     */
    class UserOverviewStatistics {
        private Long totalUsers;      // 总用户数
        private Long activeUsers;     // 活跃用户数
        private Long onlineUsers;     // 在线用户数
        private Long disabledUsers;   // 禁用用户数
        private LocalDateTime timestamp;

        // Getters and Setters
        public Long getTotalUsers() { return totalUsers; }
        public void setTotalUsers(Long totalUsers) { this.totalUsers = totalUsers; }

        public Long getActiveUsers() { return activeUsers; }
        public void setActiveUsers(Long activeUsers) { this.activeUsers = activeUsers; }

        public Long getOnlineUsers() { return onlineUsers; }
        public void setOnlineUsers(Long onlineUsers) { this.onlineUsers = onlineUsers; }

        public Long getDisabledUsers() { return disabledUsers; }
        public void setDisabledUsers(Long disabledUsers) { this.disabledUsers = disabledUsers; }

        public LocalDateTime getTimestamp() { return timestamp; }
        public void setTimestamp(LocalDateTime timestamp) { this.timestamp = timestamp; }
    }

    /**
     * 租户统计数据
     */
    class TenantStatistics {
        private Long totalTenants;                     // 总租户数
        private Long activeTenants;                    // 活跃租户数
        private Map<String, Long> tenantUserCounts;   // 各租户用户数量

        // Getters and Setters
        public Long getTotalTenants() { return totalTenants; }
        public void setTotalTenants(Long totalTenants) { this.totalTenants = totalTenants; }

        public Long getActiveTenants() { return activeTenants; }
        public void setActiveTenants(Long activeTenants) { this.activeTenants = activeTenants; }

        public Map<String, Long> getTenantUserCounts() { return tenantUserCounts; }
        public void setTenantUserCounts(Map<String, Long> tenantUserCounts) { this.tenantUserCounts = tenantUserCounts; }
    }
}
